{% set pypi_name = 'oslo.messaging' %}
{% set upstream_version = upstream_version('12.6.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack oslo.messaging library
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('PyYAML') }}
BuildRequires:  {{ py3('WebOb') }}
BuildRequires:  {{ py3('amqp') }}
BuildRequires:  {{ py3('cachetools') }}
BuildRequires:  {{ py3('confluent-kafka') }}
BuildRequires:  {{ py3('debtcollector') }}
BuildRequires:  {{ py3('eventlet') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('futurist') }}
BuildRequires:  {{ py3('greenlet') }}
BuildRequires:  {{ py3('kombu') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('monotonic') }}
BuildRequires:  {{ py3('oslo.config') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslo.log') }}
BuildRequires:  {{ py3('oslo.middleware') }}
BuildRequires:  {{ py3('oslo.serialization') }}
BuildRequires:  {{ py3('oslo.service') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('pyngus') }}
BuildRequires:  {{ py3('six') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('stevedore') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
The Oslo messaging API supports RPC and notifications over a number
of different messaging transports.

%package -n {{ py2name(py_versions='py3') }}
Summary:        OpenStack oslo.messaging library
Requires:       {{ py3('PyYAML') }}
Requires:       {{ py3('WebOb') }}
Requires:       {{ py3('amqp') }}
Requires:       {{ py3('cachetools') }}
Requires:       {{ py3('debtcollector') }}
Requires:       {{ py3('futurist') }}
Requires:       {{ py3('greenlet') }}
Requires:       {{ py3('kombu') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.log') }}
Requires:       {{ py3('oslo.middleware') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.service') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('stevedore') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 12.0.0
%endif

%description -n {{ py2name(py_versions='py3') }}
The Oslo messaging API supports RPC and notifications over a number
of different messaging transports.

This package contains the Python 3.x module.

%package -n {{ py2name(py_versions='py3') }}-doc
Summary:        Documentation for OpenStack messaging library
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description -n {{ py2name(py_versions='py3') }}-doc
The Oslo messaging API supports RPC and notifications over a number
of different messaging transports.
This package contains the documentation.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%py3_build

# generate html docs
PYTHONPATH=. PBR_VERSION=%{version} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%py3_install

%check
# NOTE(jpena): we do not want to run functional tests, just unit tests
# python3-pifpaf is not available in RDO, but loading functional tests would
# fail without it
rm -rf oslo_messaging/tests/functional
# 3 cyrus tests fail on rdo with time out
python3 -m stestr.cli run --black-regex '^oslo_messaging.tests.(functional|drivers.test_amqp_driver.TestCyrusAuthentication.test_authentication_(ok|ignore_default_realm|default_realm))'

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc README.rst ChangeLog
%{python3_sitelib}/oslo_messaging
%{python3_sitelib}/*.egg-info
%{_bindir}/oslo-messaging-send-notification

%files -n {{ py2name(py_versions='py3') }}-doc
%license LICENSE
%doc doc/build/html

%changelog
